Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1.  
  2. const uint8_t *SIGNALS[] = {
  3.     sinewave
  4.     ...
  5. };
  6.  
  7. void static inline Signal_OUT(const uint8_t *signal, uint8_t ad2, uint8_t ad1, uint8_t ad0)
  8. {
  9.     asm volatile(  
  10.         "eor r18, r18   ;r18<-0"    "\n\t"
  11.         "eor r19, r19   ;r19<-0"    "\n\t"
  12.         "1:"                        "\n\t"
  13.         "add r18, %0    ;1 cycle"           "\n\t"
  14.         "adc r19, %1    ;1 cycle"           "\n\t" 
  15.         "adc %A3, %2    ;1 cycle"           "\n\t"
  16.         "lpm            ;3 cycles"  "\n\t"
  17.         "out %4, r0     ;1 cycle"   "\n\t"
  18.         "sbis %5, 2     ;1 cycle if no skip" "\n\t"
  19.         "rjmp 1b        ;2 cycles. Total 10 cycles" "\n\t"
  20.         :
  21.         :"r" (ad0),"r" (ad1),"r" (ad2),"e" (signal),"I" (_SFR_IO_ADDR(PORTA)), "I" (_SFR_IO_ADDR(PORTD))
  22.         :"r18", "r19"
  23.     );
  24. }
  25.  
  26. Signal_OUT(SIGNALS[SG.mode], ...);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement